package maincode;
public class normalizePredRate {

	public static double getNormalizedRate(int numDays, int cursorInt){
		int length=currencyStream.getNumber();
		double daysRate[][] = new double[length][numDays];
		double normalizedEveDays[] = new double[length];

//		System.out.println("Length "+length);
		for(int i=0; i<length; i++){
			if(i != cursorInt){
				double predValueArr;
				double weightArr;
				for(int j=0; j<numDays; j++){
					int rawDataLength = currencyStream.getCurSet(i).getValues().length;
					corGenator tempCor = new corGenator(currencyStream.getCurSet(i).getValues(),currencyStream.getCurSet(cursorInt).getValues());
					predValueArr = currencyStream.getCurSet(i).getValues()[rawDataLength - j-1];
					weightArr = tempCor.returnCor(j);
//					System.out.println(i+" "+j);
					daysRate[i][j] = predValueArr*weightArr;
				}
			}	
		}
			
		for(int i=0; i<length; i++){
			double tempEveDays = 0;
			for(int j=0; j<numDays; j++)
				tempEveDays += daysRate[i][j];
			normalizedEveDays[i] = tempEveDays;
		}

		int iterLargestRate = 0;
		for(int i=0; i<length; i++){
			if(Math.abs(normalizedEveDays[i])>Math.abs(normalizedEveDays[iterLargestRate]))
				iterLargestRate = i;
		}
//		System.out.println(iterLargestRate);
		return normalizedEveDays[iterLargestRate];		
	}
}
